#!/usr/local/bin/python3
# -*- coding: utf-8 -*-

"""
@File    :models.py
@Author  :keyin
@Time    :2021-02-19 12:36
"""
from sqlalchemy import Column, String, Integer, Enum, Date, create_engine
from sqlalchemy.ext.declarative import declarative_base
db = 'Code'
my_connect = 'mysql+pymysql://root:790729@localhost:3306/{}?charset-utf8'.format(db)
        # 创建一个引擎
engine = create_engine(my_connect)
Base = declarative_base()
metadata = Base.metadata

class CardData(Base):
    __tablename__ = 'card_data'

    c_id = Column(Integer, primary_key=True, comment='id')
    c_name = Column(String(16), nullable=False, comment='姓名')
    c_sex = Column(Enum('男', '女'), comment='性别')
    c_nation = Column(String(16), comment='民族')
    c_address = Column(String(100), comment='地址')
    c_idNumber = Column(String(18), unique=True, comment='身份证号')
    c_valStart = Column(Date, comment='有效期开始日期')
    c_valEnd = Column(Date, comment='有效期结束日期')
    c_picF = Column(String(100), comment='正面路径')
    c_picB = Column(String(100), comment='反面路径')
    c_mobile = Column(String(11), comment='手机号')
    c_checkPhone = Column(String(11), comment='验照手机号')
    c_wechat = Column(String(50), comment='微信号')
    c_em = Column(Integer, comment='学历')

if __name__ == '__main__':
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
    # print([k for k in CardData.__dict__.keys() if not k.startswith('_')])